<?php
/*
 * Copyright 2009, Jeffrey Palm.
 */

/*
 * Called by any device with song information to store.
 *
 * INPUT: user
 *        artist
 *        album
 *        track
 *        time
 * OUTPUT: 'OK' - for good
 *         'NO' - for bad
 */

include 'top.php';

$user   = param('user');
$artist = param('artist');
$album  = param('album');
$track  = param('track');
$time   = param('time');

// First delete any row with this user
$sql  = 'DELETE FROM `tracks` WHERE `user` = ' . qw($user);
sql_query($sql);

// Now add another row with this user
$sql  = 'INSERT INTO `tracks` (user,artist,album,track,time,date) VALUES (';
$sql .= qw($user) . ',';
$sql .= qw($artist) . ',';
$sql .= qw($album) . ',';
$sql .= qw($track)  . ',';
$sql .= qw($time)  . ',';
$sql .= qw(timestamp());
$sql .= ')';
sql_query($sql);

echo 'OK';

include 'done.php';

?>